/*
 * Graph_topological_sort.cpp
 *
 *  Created on: 31.03.2014
 *      Author: Medvedeva Anna
 */

#include <list>
#include <stack>
#include <deque>
#include <vector>
#include <iostream>
#include "Graph.h"
#include <algorithm>

using namespace std ;

pair <int,int> timeVert(int vertex, int time)
{
	pair <int,int> curPoint(vertex,time);
	return curPoint;
}
void topological_sort(Graph graph)
{
	pair<int,int> start(0,0);
	vector <pair <int,int> > timeInfo(graph.numbVertices, start);

	pair<int,int> (*p)(int, int);
	p = timeVert;
	 (graph.dfs(0, timeInfo, p));
	if (graph.dfs(0, timeInfo, p)) {
		cout << "there are cycles, cant make topological sort\n";
		return;
	}
	reverse(timeInfo.begin(), timeInfo.end());

	cout << "topological sort:\n";
	for (size_t i = 0; i < timeInfo.size(); i++){
		cout << timeInfo[i].first + 1<< " ";
	}
}


